package com.ncut.mapper;

import com.github.pagehelper.Page;
import com.ncut.annotation.AutoFill;
import com.ncut.dto.DishPageQueryDTO;
import com.ncut.entity.Dish;
import com.ncut.enumeration.OperationType;
import com.ncut.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @FileName DIshMapper
 * @Description
 * @Author Sword
 * @date 2025-07-07
 **/

@Mapper
public interface DishMapper {

    /**
     * 新增菜品
     *
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 菜品分页查询
     *
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询菜品
     *
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    /**
     * 批量删除菜品
     *
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    /**
     * 修改菜品
     *
     * @param dish
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 根据分类id查询菜品
     *
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);

    /**
     * 查询菜品总览
     *
     * @param map
     * @return
     */
    @Select("select count(*) from dish where status = #{status}")
    Integer countByMap(Map map);
}
